/*     */ package com.umeng.common.net;
/*     */ 
/*     */ import android.content.ContentValues;
/*     */ import android.content.Context;
/*     */ import android.database.Cursor;
/*     */ import android.database.sqlite.SQLiteDatabase;
/*     */ import android.database.sqlite.SQLiteOpenHelper;
/*     */ import com.umeng.common.Log;
/*     */ import com.umeng.common.util.h;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ 
/*     */ public class c
/*     */ {
/*  50 */   private static final String a = c.class.getName();
/*     */   private static final String b = "umeng_download_task_list";
/*     */   private static final String c = "UMENG_DATA";
/*     */   private static final String d = "cp";
/*     */   private static final String e = "url";
/*     */   private static final String f = "progress";
/*     */   private static final String g = "last_modified";
/*     */   private static final String h = "extra";
/*     */   private static Context i;
/*     */   private static final String j = "yyyy-MM-dd HH:mm:ss";
/*     */   private a k;
/*     */ 
/*     */   private c()
/*     */   {
/*  64 */     this.k = new a(i);
/*     */   }
/*     */ 
/*     */   public static c a(Context paramContext)
/*     */   {
/*  72 */     if ((i == null) && (paramContext == null))
/*  73 */       throw new NullPointerException();
/*  74 */     if (i == null)
/*  75 */       i = paramContext;
/*  76 */     return b.a;
/*     */   }
/*     */ 
/*     */   public boolean a(String paramString1, String paramString2) {
/*  80 */     ContentValues localContentValues = new ContentValues();
/*  81 */     localContentValues.put("cp", paramString1);
/*  82 */     localContentValues.put("url", paramString2);
/*  83 */     localContentValues.put("progress", Integer.valueOf(0));
/*  84 */     localContentValues.put("last_modified", h.a());
/*  85 */     boolean bool = false;
/*     */     try {
/*  87 */       String str = "cp=? and url=?";
/*  88 */       String[] arrayOfString = { paramString1, paramString2 };
/*  89 */       Cursor localCursor = this.k.getReadableDatabase().query("umeng_download_task_list", 
/*  90 */         new String[] { "progress" }, str, arrayOfString, null, 
/*  91 */         null, null, "1");
/*  92 */       if (localCursor.getCount() > 0) {
/*  93 */         Log.c(a, "insert(" + paramString1 + ", " + paramString2 + "): " + 
/*  94 */           " already exists in the db. Insert is cancelled.");
/*  95 */         bool = false;
/*     */       } else {
/*  97 */         long l = this.k.getWritableDatabase().insert("umeng_download_task_list", 
/*  98 */           null, localContentValues);
/*  99 */         bool = l != -1L;
/* 100 */         Log.c(a, "insert(" + paramString1 + ", " + paramString2 + "): " + 
/* 101 */           "rowid=" + l);
/*     */       }
/* 103 */       localCursor.close();
/*     */     } catch (Exception localException) {
/* 105 */       Log.c(a, 
/* 106 */         "insert(" + paramString1 + ", " + paramString2 + "): " + localException.getMessage(), 
/* 107 */         localException);
/*     */     }
/* 109 */     return bool;
/*     */   }
/*     */ 
/*     */   public void a(String paramString1, String paramString2, int paramInt) {
/* 113 */     ContentValues localContentValues = new ContentValues();
/* 114 */     localContentValues.put("progress", Integer.valueOf(paramInt));
/* 115 */     localContentValues.put("last_modified", h.a());
/* 116 */     String str = "cp=? and url=?";
/* 117 */     String[] arrayOfString = { paramString1, paramString2 };
/* 118 */     this.k.getWritableDatabase().update("umeng_download_task_list", localContentValues, str, 
/* 119 */       arrayOfString);
/*     */ 
/* 121 */     Log.c(a, "updateProgress(" + paramString1 + ", " + paramString2 + ", " + 
/* 122 */       paramInt + ")");
/*     */   }
/*     */ 
/*     */   public void a(String paramString1, String paramString2, String paramString3) {
/* 126 */     ContentValues localContentValues = new ContentValues();
/* 127 */     localContentValues.put("extra", paramString3);
/* 128 */     localContentValues.put("last_modified", h.a());
/* 129 */     String str = "cp=? and url=?";
/* 130 */     String[] arrayOfString = { paramString1, paramString2 };
/* 131 */     this.k.getWritableDatabase().update("umeng_download_task_list", localContentValues, str, 
/* 132 */       arrayOfString);
/* 133 */     Log.c(a, "updateExtra(" + paramString1 + ", " + paramString2 + ", " + paramString3 + 
/* 134 */       ")");
/*     */   }
/*     */ 
/*     */   public int b(String paramString1, String paramString2) {
/* 138 */     int m = -1;
/* 139 */     String str = "cp=? and url=?";
/* 140 */     String[] arrayOfString = { paramString1, paramString2 };
/* 141 */     Cursor localCursor = this.k.getReadableDatabase().query("umeng_download_task_list", 
/* 142 */       new String[] { "progress" }, str, arrayOfString, null, null, 
/* 143 */       null, "1");
/* 144 */     if (localCursor.getCount() > 0) {
/* 145 */       localCursor.moveToFirst();
/* 146 */       m = localCursor.getInt(0);
/*     */     }
/* 148 */     localCursor.close();
/* 149 */     return m;
/*     */   }
/*     */ 
/*     */   public String c(String paramString1, String paramString2) {
/* 153 */     String str1 = null;
/* 154 */     String str2 = "cp=? and url=?";
/* 155 */     String[] arrayOfString = { paramString1, paramString2 };
/* 156 */     Cursor localCursor = this.k.getReadableDatabase().query("umeng_download_task_list", 
/* 157 */       new String[] { "extra" }, str2, arrayOfString, null, null, 
/* 158 */       null, "1");
/* 159 */     if (localCursor.getCount() > 0) {
/* 160 */       localCursor.moveToFirst();
/* 161 */       str1 = localCursor.getString(0);
/*     */     }
/* 163 */     localCursor.close();
/* 164 */     return str1;
/*     */   }
/*     */ 
/*     */   public Date d(String paramString1, String paramString2) {
/* 168 */     Date localDate = null;
/* 169 */     String str1 = "cp=? and url=?";
/* 170 */     String[] arrayOfString = { paramString1, paramString2 };
/* 171 */     Cursor localCursor = this.k.getReadableDatabase().query("umeng_download_task_list", 
/* 172 */       new String[] { "last_modified" }, str1, arrayOfString, null, 
/* 173 */       null, null, null);
/* 174 */     if (localCursor.getCount() > 0) {
/* 175 */       localCursor.moveToFirst();
/* 176 */       String str2 = localCursor.getString(0);
/* 177 */       Log.c(a, "getLastModified(" + paramString1 + ", " + paramString2 + "): " + 
/* 178 */         str2);
/*     */       try
/*     */       {
/* 181 */         localDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(str2);
/*     */       } catch (Exception localException) {
/* 183 */         Log.c(a, localException.getMessage());
/*     */       }
/*     */     }
/* 186 */     localCursor.close();
/* 187 */     return localDate;
/*     */   }
/*     */ 
/*     */   public void e(String paramString1, String paramString2) {
/* 191 */     String str = "cp=? and url=?";
/* 192 */     String[] arrayOfString = { paramString1, paramString2 };
/* 193 */     this.k.getWritableDatabase().delete("umeng_download_task_list", str, arrayOfString);
/* 194 */     Log.c(a, "delete(" + paramString1 + ", " + paramString2 + ")");
/*     */   }
/*     */ 
/*     */   public List<String> a(String paramString)
/*     */   {
/* 199 */     String str = "cp=?";
/* 200 */     String[] arrayOfString = { paramString };
/* 201 */     Cursor localCursor = this.k.getReadableDatabase().query("umeng_download_task_list", 
/* 202 */       new String[] { "url" }, str, arrayOfString, null, null, null, 
/* 203 */       "1");
/* 204 */     ArrayList localArrayList = new ArrayList();
/* 205 */     localCursor.moveToFirst();
/* 206 */     while (!localCursor.isAfterLast()) {
/* 207 */       localArrayList.add(localCursor.getString(0));
/* 208 */       localCursor.moveToNext();
/*     */     }
/*     */ 
/* 211 */     localCursor.close();
/* 212 */     return localArrayList;
/*     */   }
/*     */ 
/*     */   public void a(int paramInt)
/*     */   {
/*     */     try
/*     */     {
/* 228 */       Date localDate = new Date(new Date().getTime() - paramInt * 1000);
/* 229 */       String str1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
/* 230 */         .format(localDate);
/* 231 */       String str2 = " DELETE FROM umeng_download_task_list WHERE strftime('yyyy-MM-dd HH:mm:ss', last_modified)<=strftime('yyyy-MM-dd HH:mm:ss', '" + 
/* 233 */         str1 + "')";
/*     */ 
/* 235 */       this.k.getWritableDatabase().execSQL(str2);
/*     */ 
/* 237 */       Log.c(a, 
/* 238 */         "clearOverdueTasks(" + 
/* 239 */         paramInt + 
/* 240 */         ")" + 
/* 241 */         " remove all tasks before " + 
/* 242 */         new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
/* 243 */         .format(localDate));
/*     */     }
/*     */     catch (Exception localException) {
/* 246 */       Log.b(a, localException.getMessage());
/*     */     }
/*     */   }
/*     */ 
/*     */   public void finalize()
/*     */   {
/* 254 */     this.k.close();
/*     */   }
/*     */ 
/*     */   class a extends SQLiteOpenHelper
/*     */   {
/*     */     private static final int b = 2;
/*     */     private static final String c = "CREATE TABLE umeng_download_task_list (cp TEXT, url TEXT, progress INTEGER, extra TEXT, last_modified TEXT, UNIQUE (cp,url) ON CONFLICT ABORT);";
/*     */ 
/*     */     a(Context arg2)
/*     */     {
/* 268 */       super("UMENG_DATA", null, 2);
/*     */     }
/*     */ 
/*     */     public void onCreate(SQLiteDatabase paramSQLiteDatabase)
/*     */     {
/* 273 */       Log.c(c.a(), "CREATE TABLE umeng_download_task_list (cp TEXT, url TEXT, progress INTEGER, extra TEXT, last_modified TEXT, UNIQUE (cp,url) ON CONFLICT ABORT);");
/* 274 */       paramSQLiteDatabase.execSQL("CREATE TABLE umeng_download_task_list (cp TEXT, url TEXT, progress INTEGER, extra TEXT, last_modified TEXT, UNIQUE (cp,url) ON CONFLICT ABORT);");
/*     */     }
/*     */ 
/*     */     public void onUpgrade(SQLiteDatabase paramSQLiteDatabase, int paramInt1, int paramInt2)
/*     */     {
/*     */     }
/*     */   }
/*     */ 
/*     */   private static class b
/*     */   {
/*  68 */     public static final c a = new c(null);
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\umeng_sdk.jar
 * Qualified Name:     com.umeng.common.net.c
 * JD-Core Version:    0.6.2
 */